# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer:
pkgname=corectrl
pkgver=1.3.8
pkgrel=0
pkgdesc="Control your hardware with application profiles"
url="https://gitlab.com/corectrl/corectrl"
# fails to build
arch="all !armhf !armv7 !ppc64le !x86 !s390x"
license="GPL-3.0-only"
depends="
	hwdata
	procps
	qt5-qtquickcontrols2
	qt5-qtsvg
	qt5-qtxmlpatterns
	"
makedepends="
	botan-dev
	cmake
	fmt-dev
	polkit-dev
	pugixml-dev
	qt5-qtbase-dev
	qt5-qtcharts-dev
	qt5-qtquickcontrols2-dev
	qt5-qtsvg-dev
	qt5-qttools-dev
	quazip-dev
	samurai
	"
checkdepends="catch2"
source="https://gitlab.com/corectrl/corectrl/-/archive/v$pkgver/corectrl-v$pkgver.tar.bz2
	"
builddir="$srcdir/corectrl-v$pkgver"
options="!check" # one version comparison test segfaults

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DBUILD_TESTING="$(want_check && echo ON || echo OFF)" \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
099f13afd246ecbadfbe1b8e2e61dfd9a5fbecfd7dda09bbc1e28415d3729fe46b1bff11651672b13cbc5d3d8b2610ac78b367afa8f681499fe45bb7dded2588  corectrl-v1.3.8.tar.bz2
"
